package com.jsjvm.server.dbgproxy.jdwp.cmdsets;

import java.io.IOException;

import com.jsjvm.server.dbgproxy.JDPABackEnd;
import com.jsjvm.server.dbgproxy.JDWPCommandSet;
import com.jsjvm.server.dbgproxy.jdwp.data.JDWPInputStream;
import com.jsjvm.server.dbgproxy.jdwp.data.JDWPOutputStream;
import com.jsjvm.server.dbgproxy.jdwp.data.JDWPRequestHeader;
import com.jsjvm.shared.vmcmds.VMCommand;

/**
 * Query informations about a JClass
 */
@SuppressWarnings("serial")
public class JDWPReferenceTypeCommandSet extends JDWPCommandSet {
    private static final int SIGNATURE_CMD				= 1;
    private static final int CLASS_LOADER_CMD			= 2;
    private static final int MODIFIERS_CMD				= 3;
    private static final int FIELDS_CMD					= 4;
    private static final int METHODS_CMD				= 5;
    private static final int GET_VALUES_CMD				= 6;
    private static final int SOURCE_FILE_CMD			= 7;
    private static final int NESTED_TYPE_CMD			= 8;
    private static final int STATUS_CMD					= 9;
    private static final int INTERFACES_CMD				= 10;
    private static final int CLASS_OBJECT_CMD			= 11;
    private static final int SOURCE_DEBUG_EXTENSION_CMD = 12;
    private static final int SIGNATURE_GENERIC_CMD		= 13;
    private static final int FIELDS_GENERIC_CMD			= 14;
    private static final int METHODS_GENERIC_CMD		= 15;
    private static final int INSTANCES_CMD				= 16;
    private static final int CLASS_FILE_VERSION_CMD		= 17;
    private static final int CONSTANT_POOL_CMD			= 18;


	public static final int REFERENCE_TYPE_SET = 2;	
    @Override
	public int getCommandSetNumber() {
		return REFERENCE_TYPE_SET;
	}

    public JDWPReferenceTypeCommandSet() {
    	this.put(CLASS_LOADER_CMD, new GetClassLoader());
    	this.put(CONSTANT_POOL_CMD, getNIHandler());
    	this.put(SIGNATURE_GENERIC_CMD, getNIHandler());
    	this.put(FIELDS_GENERIC_CMD, getNIHandler());
    	this.put(METHODS_GENERIC_CMD, getNIHandler());
    	this.put(SOURCE_DEBUG_EXTENSION_CMD, getNIHandler());
    	this.put(INSTANCES_CMD, getNIHandler());
    }
    
    private static class GetClassLoader extends JDWPCommandHandler {
		@Override
		public VMCommand handleCommand(JDWPRequestHeader hdr, JDWPInputStream is,
				JDWPOutputStream os) throws IOException {
			os.appendInt(JDPABackEnd.CLASS_LOADER_ID);
			os.commitReplyPacket(hdr);
			return null;
		}
    }
    
    
}
